classdef RomerPacket < Packet
    properties (SetAccess = 'public', GetAccess = 'public')
        %romer parameters
        %CR - should remaining credit be (1+alpha)*c_source
        romer_alpha = 0;
        romer_c_source = 0;
        remaining_credit = 0;
    end
    
    methods
        function obj = RomerPacket(id, size_in_bytes, src_node, dest_node, route, romer_alpha, remaining_credit, c_source)
            obj = obj@Packet();
            if nargin > 0
                obj.id = id;
                obj.size_in_bytes = size_in_bytes;
                obj.src_node = src_node;
                obj.dest_node = dest_node;
                obj.route = route;
                obj.romer_alpha = romer_alpha;
                obj.remaining_credit = remaining_credit;
                obj.romer_c_source = c_source;
            end
        end
        
        function new_packet = duplicate_packet(obj)
            new_packet = RomerPacket();
            new_packet.id = obj.id;
            new_packet.size_in_bytes = obj.size_in_bytes;
            new_packet.src_node = obj.src_node;
            new_packet.dest_node = obj.dest_node;
            new_packet.current_node = obj.current_node;
            new_packet.next_node = obj.next_node;
            new_packet.route = obj.route;
            new_packet.creation_time_in_msec = obj.creation_time_in_msec;
            new_packet.delivery_time_in_msec = obj.delivery_time_in_msec;
            new_packet.romer_alpha = obj.romer_alpha;
            new_packet.romer_c_source = obj.romer_c_source;
            new_packet.remaining_credit = obj.remaining_credit;
        end
        
        function set.remaining_credit(obj, value)
            if ~(value >= 0)
              error('remaining_credit must be positive')
           else
              obj.remaining_credit = value;
           end
        end
    end
    
end
